﻿/**  版本信息模板在安装目录下，可自行修改。
* FA_ASSETSDISPOSAL.cs
*
* 功 能： N/A
* 类 名： FA_ASSETSDISPOSAL
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2013/10/14 11:18:28   N/A    初版
*
* Copyright (c) 2012 TKFA Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：TKFA　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using TKFA.IDAL;
using Maticsoft.DBUtility;//Please add references
namespace TKFA.OracleDAL
{
	/// <summary>
	/// 数据访问类:FA_ASSETSDISPOSAL
	/// </summary>
	public partial class FA_ASSETSDISPOSAL:IFA_ASSETSDISPOSAL
	{
		public FA_ASSETSDISPOSAL()
		{}
		#region  BasicMethod

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string SCORPCODE,string SPERIOD,string STRANSACTIONCODE)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from FA_ASSETSDISPOSAL");
			strSql.Append(" where SCORPCODE=:SCORPCODE and SPERIOD=:SPERIOD and STRANSACTIONCODE=:STRANSACTIONCODE ");
			OracleParameter[] parameters = {
					new OracleParameter(":SCORPCODE", OracleType.VarChar,20),
					new OracleParameter(":SPERIOD", OracleType.VarChar,20),
					new OracleParameter(":STRANSACTIONCODE", OracleType.VarChar,20)			};
			parameters[0].Value = SCORPCODE;
			parameters[1].Value = SPERIOD;
			parameters[2].Value = STRANSACTIONCODE;

			return DbHelperOra.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(TKFA.Model.FA_ASSETSDISPOSAL model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into FA_ASSETSDISPOSAL(");
			strSql.Append("SCORPCODE,SPERIOD,STRANSACTIONCODE,SASSETSCODE,SMASTERCARD_CODE,SHANDBY,SREASON,DTRANSACTIONDATE,IYEAR,SCONTENTSCODE,SALTERATIONCODE,SDESCRIPTION)");
			strSql.Append(" values (");
			strSql.Append(":SCORPCODE,:SPERIOD,:STRANSACTIONCODE,:SASSETSCODE,:SMASTERCARD_CODE,:SHANDBY,:SREASON,:DTRANSACTIONDATE,:IYEAR,:SCONTENTSCODE,:SALTERATIONCODE,:SDESCRIPTION)");
			OracleParameter[] parameters = {
					new OracleParameter(":SCORPCODE", OracleType.VarChar,20),
					new OracleParameter(":SPERIOD", OracleType.VarChar,20),
					new OracleParameter(":STRANSACTIONCODE", OracleType.VarChar,20),
					new OracleParameter(":SASSETSCODE", OracleType.VarChar,20),
					new OracleParameter(":SMASTERCARD_CODE", OracleType.VarChar,20),
					new OracleParameter(":SHANDBY", OracleType.VarChar,20),
					new OracleParameter(":SREASON", OracleType.VarChar,20),
					new OracleParameter(":DTRANSACTIONDATE", OracleType.DateTime),
					new OracleParameter(":IYEAR", OracleType.Number,4),
					new OracleParameter(":SCONTENTSCODE", OracleType.VarChar,20),
					new OracleParameter(":SALTERATIONCODE", OracleType.VarChar,20),
					new OracleParameter(":SDESCRIPTION", OracleType.VarChar,20)};
			parameters[0].Value = model.SCORPCODE;
			parameters[1].Value = model.SPERIOD;
			parameters[2].Value = model.STRANSACTIONCODE;
			parameters[3].Value = model.SASSETSCODE;
			parameters[4].Value = model.SMASTERCARD_CODE;
			parameters[5].Value = model.SHANDBY;
			parameters[6].Value = model.SREASON;
			parameters[7].Value = model.DTRANSACTIONDATE;
			parameters[8].Value = model.IYEAR;
			parameters[9].Value = model.SCONTENTSCODE;
			parameters[10].Value = model.SALTERATIONCODE;
			parameters[11].Value = model.SDESCRIPTION;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(TKFA.Model.FA_ASSETSDISPOSAL model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update FA_ASSETSDISPOSAL set ");
			strSql.Append("SASSETSCODE=:SASSETSCODE,");
			strSql.Append("SMASTERCARD_CODE=:SMASTERCARD_CODE,");
			strSql.Append("SHANDBY=:SHANDBY,");
			strSql.Append("SREASON=:SREASON,");
			strSql.Append("DTRANSACTIONDATE=:DTRANSACTIONDATE,");
			strSql.Append("IYEAR=:IYEAR,");
			strSql.Append("SCONTENTSCODE=:SCONTENTSCODE,");
			strSql.Append("SALTERATIONCODE=:SALTERATIONCODE,");
			strSql.Append("SDESCRIPTION=:SDESCRIPTION,");
			strSql.Append(" where SCORPCODE=:SCORPCODE and SPERIOD=:SPERIOD and STRANSACTIONCODE=:STRANSACTIONCODE ");
			OracleParameter[] parameters = {
					new OracleParameter(":SASSETSCODE", OracleType.VarChar,20),
					new OracleParameter(":SMASTERCARD_CODE", OracleType.VarChar,20),
					new OracleParameter(":SHANDBY", OracleType.VarChar,20),
					new OracleParameter(":SREASON", OracleType.VarChar,20),
					new OracleParameter(":DTRANSACTIONDATE", OracleType.DateTime),
					new OracleParameter(":IYEAR", OracleType.Number,4),
					new OracleParameter(":SCONTENTSCODE", OracleType.VarChar,20),
					new OracleParameter(":SALTERATIONCODE", OracleType.VarChar,20),
					new OracleParameter(":SDESCRIPTION", OracleType.VarChar,20),
					new OracleParameter(":SCORPCODE", OracleType.VarChar,20),
					new OracleParameter(":SPERIOD", OracleType.VarChar,20),
					new OracleParameter(":STRANSACTIONCODE", OracleType.VarChar,20)};
			parameters[0].Value = model.SASSETSCODE;
			parameters[1].Value = model.SMASTERCARD_CODE;
			parameters[2].Value = model.SHANDBY;
			parameters[3].Value = model.SREASON;
			parameters[4].Value = model.DTRANSACTIONDATE;
			parameters[5].Value = model.IYEAR;
			parameters[6].Value = model.SCONTENTSCODE;
			parameters[7].Value = model.SALTERATIONCODE;
			parameters[8].Value = model.SDESCRIPTION;
			parameters[9].Value = model.SCORPCODE;
			parameters[10].Value = model.SPERIOD;
			parameters[11].Value = model.STRANSACTIONCODE;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string SCORPCODE,string SPERIOD,string STRANSACTIONCODE)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from FA_ASSETSDISPOSAL ");
			strSql.Append(" where SCORPCODE=:SCORPCODE and SPERIOD=:SPERIOD and STRANSACTIONCODE=:STRANSACTIONCODE ");
			OracleParameter[] parameters = {
					new OracleParameter(":SCORPCODE", OracleType.VarChar,20),
					new OracleParameter(":SPERIOD", OracleType.VarChar,20),
					new OracleParameter(":STRANSACTIONCODE", OracleType.VarChar,20)			};
			parameters[0].Value = SCORPCODE;
			parameters[1].Value = SPERIOD;
			parameters[2].Value = STRANSACTIONCODE;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public TKFA.Model.FA_ASSETSDISPOSAL GetModel(string SCORPCODE,string SPERIOD,string STRANSACTIONCODE)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select SCORPCODE,SPERIOD,STRANSACTIONCODE,SASSETSCODE,SMASTERCARD_CODE,SHANDBY,SREASON,DTRANSACTIONDATE,IYEAR,SCONTENTSCODE,SALTERATIONCODE,SDESCRIPTION from FA_ASSETSDISPOSAL ");
			strSql.Append(" where SCORPCODE=:SCORPCODE and SPERIOD=:SPERIOD and STRANSACTIONCODE=:STRANSACTIONCODE ");
			OracleParameter[] parameters = {
					new OracleParameter(":SCORPCODE", OracleType.VarChar,20),
					new OracleParameter(":SPERIOD", OracleType.VarChar,20),
					new OracleParameter(":STRANSACTIONCODE", OracleType.VarChar,20)			};
			parameters[0].Value = SCORPCODE;
			parameters[1].Value = SPERIOD;
			parameters[2].Value = STRANSACTIONCODE;

			TKFA.Model.FA_ASSETSDISPOSAL model=new TKFA.Model.FA_ASSETSDISPOSAL();
			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public TKFA.Model.FA_ASSETSDISPOSAL DataRowToModel(DataRow row)
		{
			TKFA.Model.FA_ASSETSDISPOSAL model=new TKFA.Model.FA_ASSETSDISPOSAL();
			if (row != null)
			{
				if(row["SCORPCODE"]!=null)
				{
					model.SCORPCODE=row["SCORPCODE"].ToString();
				}
				if(row["SPERIOD"]!=null)
				{
					model.SPERIOD=row["SPERIOD"].ToString();
				}
				if(row["STRANSACTIONCODE"]!=null)
				{
					model.STRANSACTIONCODE=row["STRANSACTIONCODE"].ToString();
				}
				if(row["SASSETSCODE"]!=null)
				{
					model.SASSETSCODE=row["SASSETSCODE"].ToString();
				}
				if(row["SMASTERCARD_CODE"]!=null)
				{
					model.SMASTERCARD_CODE=row["SMASTERCARD_CODE"].ToString();
				}
				if(row["SHANDBY"]!=null)
				{
					model.SHANDBY=row["SHANDBY"].ToString();
				}
				if(row["SREASON"]!=null)
				{
					model.SREASON=row["SREASON"].ToString();
				}
				if(row["DTRANSACTIONDATE"]!=null && row["DTRANSACTIONDATE"].ToString()!="")
				{
					model.DTRANSACTIONDATE=DateTime.Parse(row["DTRANSACTIONDATE"].ToString());
				}
				if(row["IYEAR"]!=null && row["IYEAR"].ToString()!="")
				{
					model.IYEAR=decimal.Parse(row["IYEAR"].ToString());
				}
				if(row["SCONTENTSCODE"]!=null)
				{
					model.SCONTENTSCODE=row["SCONTENTSCODE"].ToString();
				}
				if(row["SALTERATIONCODE"]!=null)
				{
					model.SALTERATIONCODE=row["SALTERATIONCODE"].ToString();
				}
				if(row["SDESCRIPTION"]!=null)
				{
					model.SDESCRIPTION=row["SDESCRIPTION"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select SCORPCODE,SPERIOD,STRANSACTIONCODE,SASSETSCODE,SMASTERCARD_CODE,SHANDBY,SREASON,DTRANSACTIONDATE,IYEAR,SCONTENTSCODE,SALTERATIONCODE,SDESCRIPTION ");
			strSql.Append(" FROM FA_ASSETSDISPOSAL ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM FA_ASSETSDISPOSAL ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.STRANSACTIONCODE desc");
			}
			strSql.Append(")AS Row, T.*  from FA_ASSETSDISPOSAL T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperOra.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			OracleParameter[] parameters = {
					new OracleParameter(":tblName", OracleType.VarChar, 255),
					new OracleParameter(":fldName", OracleType.VarChar, 255),
					new OracleParameter(":PageSize", OracleType.Number),
					new OracleParameter(":PageIndex", OracleType.Number),
					new OracleParameter(":IsReCount", OracleType.Clob),
					new OracleParameter(":OrderType", OracleType.Clob),
					new OracleParameter(":strWhere", OracleType.VarChar,1000),
					};
			parameters[0].Value = "FA_ASSETSDISPOSAL";
			parameters[1].Value = "STRANSACTIONCODE";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

